import request from '@/router/axios';

export const getList = (params) => {
  return request({
    url: '/api/mes-product/mro/centerproduct/list',
    method: 'get',
    params
  });
};

export const getPageList = (current, size, params) => {
  return request({
    url: '/api/mes-product/mro-repair-register/page',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  });
};

/**
 * 标记报废
 */
export const flagScrap = (ids, imageList = [], reason, source) => {
  return request({
    url: `/api/mes-product/mro/centerproduct/scrap?reason=${reason}&source=${source}`,
    method: 'post',
    data: {
      ids,
      imageList
    }
  });
};
/**
 * 标记不良
 */
export const flagFailure = (data) => {
  return request({
    url: `/api/mes-product/mro-repair-confirm/repair-relieve`,
    method: 'post',
    data
  });
};

/**
 * 离线维修
 */
export const flagRepiar = (data) => {
  return request({
    url: `/api/mes-product//mro-repair-confirm/repair-offline`,
    method: 'post',
    data: data
  });
};

/**
 * 获取产线
 */
export const getLineList = (params) => {
  return request({
    url: `/api/mes-product/productionline/list`,
    method: 'get',
    params
  });
};

export const getDetail = (params) => {
  return request({
    url: '/api/mes-product/machine-test-data/detail-by-bad',
    method: 'get',
    params: params
  });
};

export const getRoutes = (params) => {
  return request({
    url: '/api/mes-product/process/product-route/workorder-routes',
    method: 'get',
    params: params
  });
};

export const onlineRepiar = (data) => {
  return request({
    url: `/api/mes-product/mro-repair-confirm/repair-online`,
    method: 'post',
    data: data
  });
};

export const scrap = (data) => {
  return request({
    url: `/api/mes-product//mro-repair-confirm/repair-scrap`,
    method: 'post',
    data
  });
};
export const checkFailure = (params) => {
  return request({
    url: '/api/mes-product/mro/dict/checkCode',
    method: 'get',
    params: params
  });
};

export const submitRoute = (data) => {
  return request({
    url: `/api/mes-product/mro-auto-judge-config/submit`,
    method: 'post',
    data
  });
};

export const getRouteList = (params) => {
  return request({
    url: '/api/mes-product/mro-auto-judge-config/all/list',
    method: 'get',
    params: {
      ...params
    }
  });
};

export const routeList = (params) => {
  return request({
    url: '/api/mes-product/apaasworkstation/workstation/list',
    method: 'get',
    params: params
  });
};

export const removeRoute = (routeId) => {
  return request({
    url: '/api/mes-product/mro-auto-judge-config/remove',
    method: 'get',
    params: { id: routeId }
  });
};
